package com.jiang.jixiang.ui.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.jiang.jixiang.R;
import com.jiang.jixiang.bean.TypeBean;
import com.ws.universal.tools.utils.glide.GlideUtils;

public class PayTypeAdapter extends BaseQuickAdapter<TypeBean, BaseViewHolder> {


    public PayTypeAdapter() {
        super(R.layout.item_paytype);
    }

    public void setChoosed(int indexPostion) {
        getData().get(indexPostion).setChoose(true);
        notifyDataSetChanged();
    }

    @Override
    protected void convert(@NonNull BaseViewHolder holder, TypeBean bean) {
        RelativeLayout rlLayout = holder.findView(R.id.rlLayout);
        TextView tvItemName = holder.findView(R.id.tvItemName);
        ImageView imgItem = holder.findView(R.id.imgItem);
        ImageView imgItemTwo = holder.findView(R.id.imgItemTwo);
        ImageView imgItemChoose = holder.findView(R.id.imgItemChoose);
        tvItemName.setText(bean.getName());


        if (bean.getValue().equals("stripepay")) {
            imgItemTwo.setVisibility(View.VISIBLE);
            GlideUtils.CreateImageRound(bean.getImg().get(0), imgItemTwo, R.mipmap.img_load_def, R.mipmap.img_load_def);
            GlideUtils.CreateImageRound(bean.getImg().get(1), imgItem, R.mipmap.img_load_def, R.mipmap.img_load_def);
        } else {
            imgItemTwo.setVisibility(View.GONE);
            GlideUtils.CreateImageRound(bean.getImg().get(0), imgItem, R.mipmap.img_load_def, R.mipmap.img_load_def);
        }
        if (bean.isChoose()) {
            imgItemChoose.setImageResource(R.mipmap.icon_oval_chooseed);

        } else {
            imgItemChoose.setImageResource(R.mipmap.icon_oval_choose);
        }
    }
}
